From 939e55223cefb14ec4a6866c073bd79ee75eaccc Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 13 Aug 2009 14:25:35 +0200 Subject: [PATCH] Ensure that queue_translation is paired with the right X operation The X11 queue_translation operation uses NextRequest to get the serial of the XCopyArea operation where the translation should end. However, if the gc passed to gdk_draw_drawable has a non-flushed clip region (which it commonly has now for the window clipping) then the next operation will be the GC flush, not the XCopyArea. To handle this right we now pass in the GC to be used to queue_translation and ensure that it is flushed before calling NextRequest(). --- gdk/directfb/gdkwindow-directfb.c | 1 + gdk/gdkoffscreenwindow.c | 1 + gdk/gdkwindow.c | 10 +++++----- gdk/gdkwindowimpl.h | 1 + gdk/quartz/gdkgeometry-quartz.c | 1 + gdk/quartz/gdkprivate-quartz.h | 1 + gdk/win32/gdkwindow-win32.c | 1 + gdk/x11/gdkgeometry-x11.c | 6 ++++++ gdk/x11/gdkprivate-x11.h | 1 + 9 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gdk/directfb/gdkwindow-directfb.c b/gdk/directfb/gdkwindow-directfb.c index 42196f7323..a7d3d304fd 100644 --- a/gdk/directfb/gdkwindow-directfb.c +++ b/gdk/directfb/gdkwindow-directfb.c @@ -1957,6 +1957,7 @@ gdk_directfb_window_input_shape_combine_region (GdkWindow *window, static void gdk_directfb_window_queue_translation (GdkWindow *window, + GdkGC *gc, GdkRegion *region, gint dx, gint dy) diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index f14f831e82..0029708591 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -1149,6 +1149,7 @@ gdk_offscreen_window_queue_antiexpose (GdkWindow *window, static void gdk_offscreen_window_queue_translation (GdkWindow *window, + GdkGC *gc, GdkRegion *area, gint dx, gint dy) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index eaca78100f..1c1bb32dad 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2828,16 +2828,16 @@ do_move_region_bits_on_impl (GdkWindowObject *impl_window, } tmp_gc = _gdk_drawable_get_subwindow_scratch_gc ((GdkWindow *)private); + gdk_region_get_clipbox (dest_region, ©_rect); + gdk_gc_set_clip_region (tmp_gc, dest_region); + /* The region area is moved and we queue translations for all expose events to the source area that were sent prior to the copy */ - gdk_region_offset (dest_region, -dx, -dy); /* Temporarily move to source area */ + gdk_region_offset (dest_region, -dx, -dy); /* Move to source region */ GDK_WINDOW_IMPL_GET_IFACE (private->impl)->queue_translation ((GdkWindow *)impl_window, + tmp_gc, dest_region, dx, dy); - gdk_region_offset (dest_region, dx, dy); /* back to dest area */ - gdk_region_get_clipbox (dest_region, ©_rect); - - gdk_gc_set_clip_region (tmp_gc, dest_region); gdk_draw_drawable (impl_window->impl, tmp_gc, private->impl, diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index ad1ae6b5e3..b8de4744d1 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -118,6 +118,7 @@ struct _GdkWindowImplIface gboolean (* queue_antiexpose) (GdkWindow *window, GdkRegion *update_area); void (* queue_translation) (GdkWindow *window, + GdkGC *gc, GdkRegion *area, gint dx, gint dy); diff --git a/gdk/quartz/gdkgeometry-quartz.c b/gdk/quartz/gdkgeometry-quartz.c index eceb0717f0..3e0a26f2b1 100644 --- a/gdk/quartz/gdkgeometry-quartz.c +++ b/gdk/quartz/gdkgeometry-quartz.c @@ -24,6 +24,7 @@ void _gdk_quartz_window_queue_translation (GdkWindow *window, + GdkGC *gc, GdkRegion *area, gint dx, gint dy) diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index 9590d9b561..2152b6ea43 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -187,6 +187,7 @@ void _gdk_quartz_window_scroll (GdkWindow *window, gint dx, gint dy); void _gdk_quartz_window_queue_translation (GdkWindow *window, + GdkGC *gc, GdkRegion *area, gint dx, gint dy); diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index d3414495d4..1380f0bd98 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -3576,6 +3576,7 @@ _gdk_win32_window_queue_antiexpose (GdkWindow *window, */ static void _gdk_win32_window_queue_translation (GdkWindow *window, + GdkGC *gc, GdkRegion *area, gint dx, gint dy) diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c index b00ef0558f..8efeea975c 100644 --- a/gdk/x11/gdkgeometry-x11.c +++ b/gdk/x11/gdkgeometry-x11.c @@ -231,6 +231,7 @@ gdk_window_queue (GdkWindow *window, void _gdk_x11_window_queue_translation (GdkWindow *window, + GdkGC *gc, GdkRegion *area, gint dx, gint dy) @@ -241,6 +242,11 @@ _gdk_x11_window_queue_translation (GdkWindow *window, item->u.translate.dx = dx; item->u.translate.dy = dy; + /* Ensure that the gc is flushed so that we get the right + serial from NextRequest in gdk_window_queue, i.e. the + the serial for the XCopyArea, not the ones from flushing + the gc. */ + _gdk_x11_gc_flush (gc); gdk_window_queue (window, item); } diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 871fa74fd3..bfbf3d9bdd 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -130,6 +130,7 @@ void _gdk_window_process_expose (GdkWindow *window, gboolean _gdk_x11_window_queue_antiexpose (GdkWindow *window, GdkRegion *area); void _gdk_x11_window_queue_translation (GdkWindow *window, + GdkGC *gc, GdkRegion *area, gint dx, gint dy); -- 2.30.2